const orderModel = require("./db/models")["order"];
const goodsModel = require("./db/models")["goods"];
const orderGooksModel = require("./db/models")["ordergoods"];
const userModel = require("./db/models")["user"];
async function test() {
  const o = await orderModel.create({
    address: "住在你家隔壁",
    total: 100,
    status: 1,
    userId: ""
  });
  const book = await goodsModel.findOne({ where: { id: 1 } });
  book.ordergoods = { count: 100 };
  const data = await o.addGoods(book);
  console.log(data);
}

(async () => {
  // createOneGood();
  // createUser();
  // const o = await orderModel.findOne({ where: { id: 3 }, include: ["goods"] });
  // console.log(o.goods.ordergoods);
  test();
})();

async function createOneGood() {
  const g = await goodsModel.create({
    title: "书的名字",
    desc: "书的描述",
    view: 10,
    type: "书的分类",
    img: "书的图片",
    price: 100
  });
  console.log(g);
}

async function createUser() {
  const u = await userModel.create({
    username: "kyaruary",
    password: "123456",
    email: "2294234939@qq.com"
  });
  console.log(u);
}
